package com.telsoft.data;

import com.telsoft.business.DAOHelperBusiness;
import com.telsoft.entity.GroupEntity;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class GroupDAO {
	public List<GroupEntity> getGRComponent() throws SQLException{
		List<GroupEntity> grComponents = new ArrayList<GroupEntity> ();
		Connection conn = DAOHelperBusiness.getConnection();
		Statement stm = DAOHelperBusiness.getStatement(conn);
		String sql = "SELECT * FROM GROUP_COMPONENT";
		ResultSet rs = stm.executeQuery(sql);
		while (rs.next()){
			GroupEntity grComponent = new GroupEntity();
			grComponent.setGrComID(rs.getInt("GRCOM_ID"));
			grComponent.setLibID(rs.getInt("LIB_ID"));
			grComponent.setName(rs.getString("NAME"));
			grComponent.setDetail(rs.getString("DETAIL"));
			grComponents.add(grComponent);			
		}
                DAOHelperBusiness.closeResultSet(rs);
		DAOHelperBusiness.closeStatement(stm);
		DAOHelperBusiness.closeConnection(conn);
		return grComponents;
	}
}
